﻿@using LotteryVoteMVC.Core.Application
@using LotteryVoteMVC.Core
@using LotteryVoteMVC.Models
@using LotteryVoteMVC.Resources
@using LotteryVoteMVC.Utility
@model PagedList<LotteryVoteMVC.Models.BetOrder>
@{
    ViewBag.Title = "WinReport";
    Layout = "~/Views/Shared/Main.cshtml";
}
@{decimal amount = 0, turnover = 0, comm = 0, netamount = 0, win = 0;}
@section Header{
    <script src="@Url.Content("~/Scripts/Customer/SearchHelper.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.ui.datepicker.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.ui.datepicker-" + CultureHelper.GetCurrentCulture() + ".js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Customer/TableBase.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/TableBase.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Pager/pagerGray.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
            $("#FromDate , #ToDate").attr("readonly", "readonly").datepicker();
        });
    </script>
}
@{int index = 1;}
<div id="searchBar">
    @using (Html.BeginForm())
    {
        <span>@Resource.From</span>
        @Html.TextBox("FromDate", DateTime.Today.ToShortDateString())
        <span>@Resource.To</span>
        @Html.TextBox("ToDate", DateTime.Today.ToShortDateString())
        <span>@Resource.Num</span>
        @Html.TextBox("Num")
        <span>@Resource.Company</span>
        @Html.Partial("~/Views/Partial/TodayCompany.cshtml", TodayLotteryCompany.Instance.GetTodayCompany())
        <span>@Resource.GameType</span>
        @Html.Partial("~/Views/Partial/GamePlayWay.cshtml", LotterySystem.Current.GamePlayWays)
        <span>@Resource.Sort</span>
        <select id="Sort" name="Sort">
            <option value="@BetOrder.DRAWRESULT">@Resource.WinLost</option>
            <option vlaue="@BetOrder.AMOUNT">@Resource.Amount</option>
            <option value="@BetOrder.TURNOVER">@Resource.Turnover</option>
            <option value="@BetOrder.COMMISSION">@Resource.Commission</option>
        </select>
        <select id="SortType" name="SortType">
            <option value="DESC">@Resource.Desc</option>
            <option value="ASC">@Resource.Asc</option>
        </select>
        <input type="submit" name="search" id="search" value="@Resource.Search" />
    }
</div>
<table>
    <thead>
        <tr>
            <td>@Resource.No
            </td>
            <td>@Resource.SheetNum
            </td>
            <td>@Resource.OrderNo
            </td>
            <td>@Resource.UserName
            </td>
            <td>@Resource.Num
            </td>
            <td>@Resource.Company
            </td>
            <td>@Resource.GameType
            </td>
            <td>@Resource.Amount
            </td>
            <td>@Resource.Turnover
            </td>
            <td>@Resource.Odds
            </td>
            <td>@Resource.Commission
            </td>
            <td>@Resource.Net
            </td>
            <td>@Resource.NetAmount
            </td>
            <td>@Resource.Win
            </td>
            <td>@Resource.IPAddress
            </td>
            <td>@Resource.Time
            </td>
        </tr>
    </thead>
    <tbody>
        @foreach (var order in Model)
        { 
            <tr>
                <td>@(index++)
                </td>
                <td>@order.SheetId
                </td>
                <td>@order.OrderId
                </td>
                <td>@order.UserName
                </td>
                <td>@order.Num
                </td>
                <td>@LotterySystem.Current.FindCompany(order.CompanyId).Name
                </td>
                <td>@Extended.GetGPWDescription(order.GamePlayWayId)
                </td>
                <td>@order.Amount.ToString("N")
                </td>
                <td>@order.Turnover.ToString("N")
                </td>
                <td>@order.Odds
                </td>
                <td>@order.Commission.ToString("N")
                </td>
                <td @(order.DropWater > 0 ? "class=red" : string.Empty)>@order.Net.ToString("N")
                </td>
                <td>@order.NetAmount.ToString("N")
                </td>
                <td>@order.DrawResult.ToString("N")
                </td>
                <td>@order.IPAddress
                </td>
                <td>@order.CreateTime
                </td>
            </tr>
            amount += order.Amount;
            turnover += order.Turnover;
            comm += order.Commission;
            netamount += order.NetAmount;
            win += order.DrawResult;
        }
    </tbody>
    <tfoot>
        <tr>
            @for (int i = 0; i < 6; i++)
            { <td>
            </td>}
            <td>@Resource.Total
            </td>
            <td>@amount.ToString("N")
            </td>
            <td>@turnover.ToString("N")
            </td>
            <td>
            </td>
            <td>@comm.ToString("N")
            </td>
            <td>
            </td>
            <td>@netamount.ToString("N")
            </td>
            <td>@win.ToString("N")
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
    </tfoot>
</table>
@Html.Pager(Model)